package com.prd.api.factory;

import com.prd.api.RemoteUserService;
import com.prd.util.Remote;
import com.prd.vo.UserVo;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserService> {
    @Override
    public RemoteUserService create(Throwable throwable) {
        return new RemoteUserService() {
            @Override
            public Remote<List<UserVo>> listInfo(Long[] ids) {
                return Remote.fail(throwable.getMessage());
            }
        };
    }
}
